<template>
	<view class="" style="width: 100%;min-height: 100vh;"
		:style="{background:'url('+Imgbase+'/new_goodmy_bgc.png)','background-size':'100%',}">

		<view class="padding-top-60 padding-left-40 ">
			<view class="">
				<image class="w-80 h-80" :src="Imgbase + '/new_goodlx_img1.png'" mode="aspectFit" @click="back">
				</image>

			</view>
		</view>

		<view class="w100 text-center padding-top-80">
			<image class="w-285 h-65" :src="Imgbase + '/new_goodcdk_img1.png'" mode="aspectFit">
			</image>
		</view>


		<view class="w-625 padding-top-35 margin-auto">
			<view class="" style="text-align: right;margin-bottom: -12rpx;">
				<image class="w-125 h-95" :src="Imgbase + '/new_goodcdk_img4.png'" mode="aspectFit">
				</image>
			</view>
			<view class="w100 h-90 lh-90 radius-45 intitem df alc padding-left-50">
				<input style="color: #000;" class="w100 font-30 font-weight-500" type="text" v-model="code"
					placeholder-style="color: #E0D6BD;" placeholder="请填写CDK" />
			</view>
		</view>

		<view class="w100 text-center radius-20 padding-top-400">
			<image @click="excbtn" class="w-460 h-100" :src="Imgbase + '/new_goodcdk_img3.png'" mode="aspectFit">
			</image>
		</view>

		<u-popup :show="show" @close="close" mode="center" closeOnClickOverlay bgColor="transparent">
			<view class="h-900 w-650 text-center"
				:style="{background:'url('+Imgbase+'/new1_infinite_boxtanchuangbgc.png) no-repeat','background-size':'100% 100%'}">
				<view class="padding-top-180 ">
					<image class="w-300 h-300" :src="info.adimage" mode="aspectFit"></image>
				</view>
				<view class="font-35 font-weight-500 margin-bottom-120">
					{{info.name}}
				</view>
				<view class="btn w-250 h-80 radius-20  flex-center fff" @click="show = false">
					确定
				</view>

			</view>
		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				Imgbase: getApp().globalData.Imgbase,
				code: '',
				show: false,
				info: []
			}
		},
		onLoad(e) {

		},
		onShow() {

		},
		methods: {
			back() {
				uni.navigateBack()
			},
			close() {
				this.show = false
			},
			copytext() {
				let _this = this
				uni.getClipboardData({
					success: function(res) {
						uni.hideToast()
						console.log('获取成功', res.data);
						_this.code += res.data
					}
				})
			},
			excbtn() {
				if (this.code == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入兑换码'
					});
				} else {
					this.cdkExc()
				}
			},
			goback() {
				uni.navigateBack()
			},
			// 标签列表
			async cdkExc() {
				let _this = this
				let item = await this.$api.post('user/cdkExc', {
					token: uni.getStorageSync('token'),
					code: this.code
				})
				if (item.code == 1) {
					_this.code = ''
					this.show = true
					this.info = item.data.info
					// uni.showToast({
					// 	icon: 'none',
					// 	title: '兑换成功'
					// });
				}
			},
		},
	}
</script>

<style lang="less" scoped>
	.intitem {
		border: solid 3rpx #d7792e;
		background-color: #C4AE9C;
	}

	.btn {
		background-color: #F58A4F;
		margin: 35rpx auto;
	}


	.zinde {
		position: relative;
		z-index: 99;

		.title {
			position: absolute;
			width: 100%;
			text-align: center;
			top: 115rpx;
			color: #fff;
			font-size: 40rpx;
			font-weight: bold;
			text-shadow: 6rpx 6rpx 6rpx #3b3b3b;
		}
	}
</style>